Class: Renalware::HD::PrescriptionAdministrationsController

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

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject

POST JS issues - user validation not working



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

def create
  administration = hd_patient.prescription_administrations.build(
    prescription_administration_parameters
  )
  clear_irrelevant_attributes_if_drug_was_not_administered(administration)
  authorize administration
  if administration.save_by(current_user)
    # will render create.js
  else
    render_new(administration) # re-display dialog with errors
  end
end

#indexObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/renalware/hd/prescription_administrations_controller.rb', line 11

def index
  hd_patient = HD.cast_patient(patient)
  administrations = hd_patient
    .prescription_administrations
    .includes(:administered_by, :witnessed_by, :reason, :prescription)
    .ordered
    .page(page)
    .per(per_page)
  authorize administrations
  render locals: { prescription_administrations: administrations }
end

#newObject

GET HTML



24
25
26
27
28
29
30
31
# File 'app/controllers/renalware/hd/prescription_administrations_controller.rb', line 24

def new
  administration = hd_patient.prescription_administrations.build(
    prescription: prescription,
    administered_by: current_user,
    recorded_on: Date.current
  )
  render_new(administration)
end