Class: Renalware::PD::RegimesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- ApplicationController
- BaseController
- BaseController
- Renalware::PD::RegimesController
- Includes:
- Concerns::Pageable
- Defined in:
- app/controllers/renalware/pd/regimes_controller.rb
Instance Method Summary collapse
- #apd_regimes ⇒ Object
- #capd_regimes ⇒ Object
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#apd_regimes ⇒ Object
24 25 26 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 24 def apd_regimes @apd_regimes ||= APDRegime.for_patient(patient).with_bags.ordered.page(1).per(5) end |
#capd_regimes ⇒ Object
20 21 22 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 20 def capd_regimes @capd_regimes ||= CAPDRegime.for_patient(patient).with_bags.ordered.page(1).per(5) end |
#create ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 37 def create result = CreateRegime.new(patient: patient) .call(by: current_user, params: pd_regime_params) if result.success? redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("PD regime") else flash.now[:error] = failed_msg_for("PD Regime") render :new, locals: { regime: result.object, patient: patient } end end |
#edit ⇒ Object
52 53 54 55 56 57 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 52 def edit render :edit, locals: { regime: pd_regime, patient: patient } end |
#index ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 11 def index regimes = regime_type_class.for_patient(patient).with_bags.ordered.page(page).per(per_page) render locals: { patient: patient, regimes: regimes, pd_type_string: pd_type_string } end |
#new ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 28 def new regime = cloned_last_known_regime_of_type || patient.pd_regimes.new(type: regime_type) render :new, locals: { regime: regime, patient: patient } end |
#show ⇒ Object
74 75 76 77 78 79 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 74 def show render :show, locals: { regime: pd_regime, patient: patient } end |
#update ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/renalware/pd/regimes_controller.rb', line 59 def update result = ReviseRegime.new(pd_regime).call(by: current_user, params: pd_regime_params) if result.success? redirect_to patient_pd_dashboard_path(patient), notice: t(".success", model_name: "PD regime") else flash.now[:error] = t(".failed", model_name: "PD regime") render :edit, locals: { regime: result.object, patient: patient } end end |