Class: Renalware::Patients::PrimaryCarePhysiciansController

Inherits:
BaseController show all
Includes:
Concerns::Pageable
Defined in:
app/controllers/renalware/patients/primary_care_physicians_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/renalware/patients/primary_care_physicians_controller.rb', line 34

def create
  @primary_care_physician = PrimaryCarePhysician.new(primary_care_physician_params)
  authorize @primary_care_physician

  if @primary_care_physician.save
    redirect_to patients_primary_care_physicians_path,
      notice: t(".success", model_name: "primary_care_physician")
  else
    @alternative_address = alternative_address
    flash.now[:error] = t(".failed", model_name: "primary_care_physician")
    render :new
  end
end

#destroyObject



56
57
58
59
60
61
# File 'app/controllers/renalware/patients/primary_care_physicians_controller.rb', line 56

def destroy
  authorize PrimaryCarePhysician.destroy(params[:id])

  redirect_to patients_primary_care_physicians_path,
    notice: t(".success", model_name: "primary_care_physician")
end

#editObject



30
31
32
# File 'app/controllers/renalware/patients/primary_care_physicians_controller.rb', line 30

def edit
  render_form(@primary_care_physician, :edit)
end

#indexObject



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

def index
  primary_care_physicians = PrimaryCarePhysician.order(:name)
                                                .includes(:address)
                                                .eager_load(practices: :address)
                                                .page(page)
                                                .per(per_page)
  authorize primary_care_physicians
  render locals: { primary_care_physicians: primary_care_physicians }
end

#newObject



24
25
26
27
28
# File 'app/controllers/renalware/patients/primary_care_physicians_controller.rb', line 24

def new
  @primary_care_physician = PrimaryCarePhysician.new
  @alternative_address = alternative_address
  authorize @primary_care_physician
end

#updateObject



48
49
50
51
52
53
54
# File 'app/controllers/renalware/patients/primary_care_physicians_controller.rb', line 48

def update
  if @primary_care_physician.update(primary_care_physician_params)
    update_primary_care_physician_successful(@primary_care_physician)
  else
    update_primary_care_physician_failed(@primary_care_physician)
  end
end